import request from '@/utils/request.js'

const state = {
	indexData: {}
}
const actions = {
	// 获取首页数据
	async getIndexData({commit}) {
		const res = await request('/indexData')
		commit("GET_INDEX_DATA", res.indexData)
	}
}
const mutations = {
	// 更新首页数据
	"GET_INDEX_DATA"(state, val) {
		state.indexData = val
	}
}
const getters = {
	// 金刚区导航数据
	primary_filter: state => state.indexData.headData && state.indexData.headData.data.primary_filter,
	// 轮播图数据
	top_banner_list: state => state.indexData.topBannerData && state.indexData.topBannerData.data.top_banner_list,
	// 商家信息列表
	poilist: state => state.indexData.homeList && state.indexData.homeList.data.poilist,
	// 
}

export default {
	state, actions, mutations, getters
}